using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class ShareQRCodePreViewPage : BasePage
	{
		private const string TAG = "ShareQRCodePreViewPage";
		private SendCardType mSendCardType;
		private EventWatcher mWatchContactListChange;
		private ApplicationBar mBar;
		internal Grid LayoutRoot;
		internal panelTitle2Line panelTitle;
		internal UserQRCodeCtrl userQRCodeCtrl;
		private bool _contentLoaded;
		public ShareQRCodePreViewPage()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.Page_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Page_Unloaded));
			this.setAppBar();
		}
		private void Page_Loaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShareQRCodePreViewPage", "Page_Loaded");
		}
		private void Page_Unloaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShareQRCodePreViewPage", "Page_Unloaded");
		}
		protected override void OnPageIn(object[] object_0)
		{
			Log.smethod_5("ShareQRCodePreViewPage", "OnPageIn");
			if (object_0 != null && object_0.Length != 0)
			{
				if (object_0[0].GetType() == typeof(SendCardType))
				{
					this.mSendCardType = (SendCardType)object_0[0];
					this.userQRCodeCtrl.Init(new UITaskDlgEx(this.doWithUserQrCodeCtrl));
					return;
				}
			}
			base.GoBack();
		}
		protected override void OnPageOut()
		{
			Log.smethod_5("ShareQRCodePreViewPage", "OnPageOut");
			this.userQRCodeCtrl.UnInit();
		}
		protected override void OnPageBack()
		{
			Log.smethod_5("ShareQRCodePreViewPage", "OnPageBack");
		}
		private void registerEvent()
		{
			if (this.mWatchContactListChange == null)
			{
				this.mWatchContactListChange = new EventWatcher(this, this, new EventHandlerDelegate(this.OnContactChange));
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchContactListChange);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchContactListChange != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchContactListChange);
				this.mWatchContactListChange = null;
			}
		}
		private void OnContactChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
		}
		private void releaseCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		private void getCover(string string_0)
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, string_0, null, false, false, null);
		}
		private ApplicationBar setAppBar()
		{
			if (this.mBar != null)
			{
				if (!this.mBar.get_IsVisible())
				{
					this.mBar.set_IsVisible(true);
				}
				return this.mBar;
			}
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			ApplicationBarIconButton applicationBarIconButton = new ApplicationBarIconButton(new Uri("/Resource/Img/ContactList/Ico_AppBar_SendMsg.png", 2));
			applicationBarIconButton.set_Text(strings.FF_QRCode_Share);
			applicationBarIconButton.add_Click(new EventHandler(this.btnShare_Click));
			this.mBar.get_Buttons().Add(applicationBarIconButton);
			base.set_ApplicationBar(this.mBar);
			this.setAppBarStyle(base.get_ApplicationBar());
			return this.mBar;
		}
		private void btnShare_Click(object sender, EventArgs e)
		{
			ToolFunction.GotoPageForUserControl("/Source/Plugin/QRCode/UI/EditQRCodeContentPage.xaml", new object[]
			{
				this.mSendCardType
			}, false);
		}
		private void btnMenu_Click(object sender, EventArgs e)
		{
		}
		protected override void OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
		}
		private void doWithUserQrCodeCtrl(object object_0)
		{
			if (object_0 == null)
			{
				return;
			}
			UserQRCodeOp userQRCodeOp = (UserQRCodeOp)object_0;
			if (UserQRCodeOp.OpKind_DownLoadStart == userQRCodeOp)
			{
				this.getCover(strings.FF_QRCode_Generating);
				return;
			}
			if (UserQRCodeOp.OpKind_DownLoadEnd == userQRCodeOp)
			{
				this.releaseCover();
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/QRCode/UI/ShareQRCodePreViewPage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.userQRCodeCtrl = (UserQRCodeCtrl)base.FindName("userQRCodeCtrl");
		}
	}
}
